<template>
  <div class="detail" v-if="detail">
  <van-nav-bar title="商品详情页" left-text="返回" left-arrow  >
  <template #right>
    <van-icon name="shopping-cart-o" size="20" />
  </template>
   </van-nav-bar>

    <img :src="detail.coverImg" alt="">
    <div class="name">{{detail.name}}</div> 
    <p>￥{{detail.price}}</p>
    <div class="box">
      <div class="box1">
        <p>颜色</p>
        <span><img :src="detail.coverImg" alt=""></span>
      </div>
      <div class="box2">
        <p>尺码</p>
        <span>均码</span>
      </div>
      <div class="box3">
        <p>数量</p>
        <van-stepper v-model="value" integer />
      </div>
      <div class="box4">
        <p>用户评价</p>
      </div>
    </div>
  <van-goods-action>
  <van-goods-action-icon icon="shopping-cart-o" text="首页" />
  <van-goods-action-icon icon="like-o" text="收藏" />
  <van-goods-action-button color="#ef524b" type="danger" text="立即购买" />
  <van-goods-action-button color="#ff8a3b" :to="{name:'Cart'}" type="warning" text="加入购物车" />
</van-goods-action>
    </div>
</template>
<script>
import axios from 'axios'
import { Toast } from 'vant';
export default {
  components: {},
  data() {
    return {
      value:"",
      detail:null,
    };
  },
  computed: {},
  watch: {},

  methods: {
    onClickIcon() {
      Toast('点击图标');
    },
    onClickButton() {
      Toast('点击按钮');
    },
    async getDetail(id){
       const result = await axios.get(`http://192.168.12.53:3009/api/v1/products/${id}`)
       console.log(result);
       if(result){
         this.detail=result.data;
       }
    }
  },
  created() {
    const id =this.$route.query.id;
    this.getDetail(id)
  },
  mounted() {},
};
</script>
<style scoped>
.header{
  width: 100%;
  height: 45px;
}
.detail img{
  width: 100%;
  height: 414px;
}
.detail .name{
  font-size: 18px;
  margin: 0 0 4px;
  color: #000;
  font-weight: 900;
}
.detail p{
  color: red;
  font-size: 28px;
}
.box{
  width: 100%;
  height: 100%;
  margin-top: 10px;
}
.box1 p{
  font-size: 14px;
  color: black;
  font-weight: 800;
}
.box1 span img{
  width: 50px;
  height: 50px;
  border: 1px red solid;
}
.box1{
  display: flex;
  justify-items: center;
  align-items: center;
  justify-content: space-between;
  padding: 6px 20px;
  border-bottom: 1px solid rgba(193, 193, 191, 0.8);
  margin: 5px 15px
}

.box2 p{
  font-size: 14px;
  color: black;
  font-weight: 800;
}
.box2 span{
  display: block;
  width: 46px;
  height: 25px;
  background: #ef524b;
  text-align: center;

}
.box2{
  /* margin-top: 15px;
  margin-bottom: 15px; */
  display: flex;
  justify-items: center;
  align-items: center;
  justify-content: space-between;
  padding: 22px 20px;
   border-bottom: 1px solid rgba(193, 193, 191, 0.8);
   margin: 5px 15px
}
.box3{
  display: flex;
  justify-items: center;
  justify-content: space-between;
  padding: 22px 20px;
  margin: 5px 15px
}
.box3 p{
  font-size: 14px;
  color: black;
  font-weight: 800;
}
.box4{
  margin-bottom: 100px;
}
.box4 p{
  color: rgb(94, 94, 91);
  font-size: 20px;
}
</style>